package org.record.mood.service.impl;

import org.record.mood.bean.Login;
import org.record.mood.bean.LoginExample;
import org.record.mood.bean.MessageExample;
import org.record.mood.common.DateUtils;
import org.record.mood.common.RecordConst;
import org.record.mood.dao.FriendsMapper;
import org.record.mood.dao.LoginMapper;
import org.record.mood.dao.MessageMapper;
import org.record.mood.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: sunyw
 * @time: 2020-04-17 10:08
 */
@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;
    @Autowired
    private FriendsMapper friendsMapper;
    @Autowired
    private LoginMapper loginMapper;

    @Override
    public String countMessage() {
        int i = messageMapper.selectCountMessage();
        String count = "0";
        if (i > 0) {
            count = String.valueOf(i);
        }
        return count;
    }

    @Override
    public String countFriends() {
        int i = friendsMapper.selectCounts();
        String count = "0";
        if (i > 0) {
            count = String.valueOf(i);
        }
        return count;
    }

    @Override
    public Login countForCreate() {
        LoginExample example =new LoginExample();
        example.createCriteria().andStatusEqualTo(RecordConst.status.RELEASE);
        List<Login> loginList = loginMapper.selectByExample(example);
        Login login = loginList.get(0);
        return login;
    }
}
